<?php

namespace App\Http\Middleware;

use Closure;

class LoginMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    
    //操作方法
    public function handle($request, Closure $next)
    {
        //检测当前是否具有登录的session
        //$request 请求报文 
        //$request包含session数据
        if ($request->session()->has('id')) {
            return $next($request);       
        } else {
            // 跳转到登录界面
            return redirect('login');
        }
        
    }
}
